import { useState } from 'react'
function App () {
  let [count, setCount] = useState(0)
  const [from, setFrom] = useState({
    name: '张三',
  })
  // 状态只读，直接修改数值变视图不变，所以需要使用setCount
  const addCount = () => {
    count++
    console.log(count)
  }
  // 修改对象状态
  function changeName () {
    setFrom({
      ...from,
      name: '李四'
    })
  }
  return (
    <div className="App">
      <button onClick={() => { setCount(count + 1) }}>{count}</button>
      <div>
        <button onClick={addCount}>{count}</button>
      </div>
      <div>{from.name}</div>
      <button onClick={changeName}>click me</button>
    </div>
  )
}

export default App
